package com.yequan.file.walkfiletree;

import com.yequan.file.delete.FileUtil;
import com.yequan.thread.threadpool.prioritythreadpool.PriorityThreadPoolExecutor;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.concurrent.TimeUnit;

/**
 * @author : Administrator
 * @date : 2020/5/20
 */
public class WalkFileTree {

    public static void main(String[] args) throws IOException {
        String strPath = "E:\\TEMP\\ant";
        Path path = Paths.get(strPath);
        long start = System.currentTimeMillis();
        Files.walkFileTree(path, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
                System.out.println(file.getFileName());
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                System.out.println(dir.getFileName());
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                return super.visitFileFailed(file, exc);
            }
        });
        System.out.println("耗时: " + (System.currentTimeMillis() - start) + " ms");
    }

}
